<?php
require_once("include/conexion.php");
$token = "ccf4ea1073d17b7640fc146a324d8b2a";
if(isset($_POST["token"]) && $token==$_POST["token"]){
	$con = new Conexion();
	if($con->getStatus()=="0x0"){
		$buffer = $con->getAllMovies();
		if($buffer == "0x1"){
			$response["code"] = "E0x4";
			$response["gls"] = "Error al obtener datos desde la BD";
		}elseif($buffer =="0x0"){
			$response["code"] = "E0x0";
			$response["gls"] = "No existen datos";
		}else{
			$response["code"] = "0x0";
			$response["data"] = $buffer;
		}
	}else{
		$response["code"] = "E0x3";
		$response["gls"] = "Error al conectar a la base de datos";
	}
}else{
	$response["code"] = "E0x2";
	$response["gls"] = "Token invalido o no existe";
}

if(isset($_GET['callback'])){
	echo $_GET['callback'].'('.json_encode($response).')';
}else{
	echo json_encode($response);
}
?>